﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace DigitalSolutionLibrary.SqlDatabase
{
    public class Parameter
    {
        private SqlParameter sqlParam;

        /// <summary>
        /// Create parameter for store proceduce
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        /// <param name="paramDbType"></param>
        public Parameter(string paramName, object paramValue, SqlDbType paramDbType)
        {
            sqlParam = new SqlParameter();
            sqlParam.SqlDbType = paramDbType;
            sqlParam.Direction = ParameterDirection.Input;
            sqlParam.ParameterName = paramName;
            sqlParam.Value = paramValue;
            sqlParam.IsNullable = true;
        }

        /// <summary>
        /// Create parameter for store proceduce
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        /// <param name="paramDbType"></param>
        /// <param name="paramSize"></param>
        public Parameter(string paramName, object paramValue, SqlDbType paramDbType, int paramSize)
        {
            sqlParam = new SqlParameter();
            sqlParam.SqlDbType = paramDbType;
            sqlParam.Direction = ParameterDirection.Input;
            sqlParam.ParameterName = paramName;
            sqlParam.Value = paramValue;
            sqlParam.Size = paramSize;
            sqlParam.IsNullable = true;
        }

        /// <summary>
        /// Create parameter for store proceduce
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        /// <param name="paramDbType"></param>
        /// <param name="paramDirection"></param>
        public Parameter(string paramName, object paramValue, SqlDbType paramDbType, ParameterDirection paramDirection)
        {
            sqlParam = new SqlParameter();
            sqlParam.SqlDbType = paramDbType;
            sqlParam.Direction = paramDirection;
            sqlParam.ParameterName = paramName;
            sqlParam.Value = paramValue;
            sqlParam.IsNullable = true;
        }

        /// <summary>
        /// Create parameter for store proceduce
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        /// <param name="paramDbType"></param>
        /// <param name="paramDirection"></param>
        /// <param name="paramSize"></param>
        public Parameter(string paramName, object paramValue, SqlDbType paramDbType, ParameterDirection paramDirection, int paramSize)
        {
            sqlParam = new SqlParameter();
            sqlParam.SqlDbType = paramDbType;
            sqlParam.Direction = paramDirection;
            sqlParam.ParameterName = paramName;
            sqlParam.Value = paramValue;
            sqlParam.Size = paramSize;
            sqlParam.IsNullable = true;
        }

        /// <summary>
        /// Get SqlParameter
        /// </summary>
        /// <returns>SqlParameter</returns>
        public SqlParameter GetParameter()
        {
            return sqlParam;
        }

        public object ValueOut
        {
            get
            {
                return sqlParam.Value;
            }
        }
    }
}
